<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="客户编号" prop="customerCode">
        <el-input
          v-model="queryParams.customerCode"
          placeholder="请输入客户编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务区域" prop="businessArea">
        <el-input
          v-model="queryParams.businessArea"
          placeholder="请输入业务区域"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责销售(作废)" prop="salesPerson">
        <el-input
          v-model="queryParams.salesPerson"
          placeholder="请输入负责销售(作废)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省份" prop="province">
        <el-input
          v-model="queryParams.province"
          placeholder="请输入省份"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="城市" prop="city">
        <el-input
          v-model="queryParams.city"
          placeholder="请输入城市"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区县" prop="district">
        <el-input
          v-model="queryParams.district"
          placeholder="请输入区县"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入单位地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人" prop="contactPerson">
        <el-input
          v-model="queryParams.contactPerson"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开户行&账号" prop="bankAccount">
        <el-input
          v-model="queryParams.bankAccount"
          placeholder="请输入开户行&账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="税号" prop="taxId">
        <el-input
          v-model="queryParams.taxId"
          placeholder="请输入税号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电话" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="传真" prop="fax">
        <el-input
          v-model="queryParams.fax"
          placeholder="请输入传真"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="邮编" prop="zipcode">
        <el-input
          v-model="queryParams.zipcode"
          placeholder="请输入邮编"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="网址" prop="website">
        <el-input
          v-model="queryParams.website"
          placeholder="请输入网址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="应收余额" prop="receivableBalance">
        <el-input
          v-model="queryParams.receivableBalance"
          placeholder="请输入应收余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="在用品规" prop="inUseSpecs">
        <el-input
          v-model="queryParams.inUseSpecs"
          placeholder="请输入在用品规"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购记录" prop="purchaseRecords">
        <el-input
          v-model="queryParams.purchaseRecords"
          placeholder="请输入采购记录"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="首营触发" prop="firstSaleTrigger">
        <el-input
          v-model="queryParams.firstSaleTrigger"
          placeholder="请输入首营触发"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流向提交方式：手工上传、直连数据" prop="flowSubmissionMethod">
        <el-input
          v-model="queryParams.flowSubmissionMethod"
          placeholder="请输入流向提交方式：手工上传、直连数据"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流向上传记录" prop="flowUploadRecords">
        <el-input
          v-model="queryParams.flowUploadRecords"
          placeholder="请输入流向上传记录"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;签订地址" prop="shippingAddress">
        <el-input
          v-model="queryParams.shippingAddress"
          placeholder="请输入发货&gt;签订地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;供方授权代表" prop="shippingRepresentative">
        <el-input
          v-model="queryParams.shippingRepresentative"
          placeholder="请输入发货&gt;供方授权代表"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;联系电话" prop="shippingContact">
        <el-input
          v-model="queryParams.shippingContact"
          placeholder="请输入发货&gt;联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;公司电话" prop="shippingCompanyPhone">
        <el-input
          v-model="queryParams.shippingCompanyPhone"
          placeholder="请输入发货&gt;公司电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;单位地址" prop="shippingUnitAddress">
        <el-input
          v-model="queryParams.shippingUnitAddress"
          placeholder="请输入发货&gt;单位地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;仓库地址" prop="shippingWarehouseAddress">
        <el-input
          v-model="queryParams.shippingWarehouseAddress"
          placeholder="请输入发货&gt;仓库地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货&gt;开户行&账号" prop="shippingBankAccount">
        <el-input
          v-model="queryParams.shippingBankAccount"
          placeholder="请输入发货&gt;开户行&账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所有人可用：所有人可用" prop="availableToAll">
        <el-input
          v-model="queryParams.availableToAll"
          placeholder="请输入所有人可用：所有人可用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商业数据" prop="commercialData">
        <el-input
          v-model="queryParams.commercialData"
          placeholder="请输入商业数据"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="档案来源" prop="archiveSource">
        <el-input
          v-model="queryParams.archiveSource"
          placeholder="请输入档案来源"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间" prop="createdOn">
        <el-date-picker clearable
          v-model="queryParams.createdOn"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="更新时间" prop="updatedOn">
        <el-date-picker clearable
          v-model="queryParams.updatedOn"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择更新时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hbs:bussinessArchive:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hbs:bussinessArchive:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hbs:bussinessArchive:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hbs:bussinessArchive:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="bussinessArchiveList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键ID" align="center" prop="id" />
      <el-table-column label="档案状态" align="center" prop="archiveStatus" />
      <el-table-column label="合作类型" align="center" prop="cooperationType" />
      <el-table-column label="客户编号" align="center" prop="customerCode" />
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="客户类型" align="center" prop="customerType" />
      <el-table-column label="证照情况" align="center" prop="licenseStatus" />
      <el-table-column label="一级部门" align="center" prop="departmentLevel1" />
      <el-table-column label="二级部门" align="center" prop="departmentLevel2" />
      <el-table-column label="业务区域" align="center" prop="businessArea" />
      <el-table-column label="负责销售(作废)" align="center" prop="salesPerson" />
      <el-table-column label="省份" align="center" prop="province" />
      <el-table-column label="城市" align="center" prop="city" />
      <el-table-column label="区县" align="center" prop="district" />
      <el-table-column label="单位地址" align="center" prop="address" />
      <el-table-column label="联系人" align="center" prop="contactPerson" />
      <el-table-column label="开户行&账号" align="center" prop="bankAccount" />
      <el-table-column label="税号" align="center" prop="taxId" />
      <el-table-column label="电话" align="center" prop="phone" />
      <el-table-column label="传真" align="center" prop="fax" />
      <el-table-column label="邮编" align="center" prop="zipcode" />
      <el-table-column label="网址" align="center" prop="website" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="应收余额" align="center" prop="receivableBalance" />
      <el-table-column label="在用品规" align="center" prop="inUseSpecs" />
      <el-table-column label="采购记录" align="center" prop="purchaseRecords" />
      <el-table-column label="首营触发" align="center" prop="firstSaleTrigger" />
      <el-table-column label="流向提交方式：手工上传、直连数据" align="center" prop="flowSubmissionMethod" />
      <el-table-column label="流向上传记录" align="center" prop="flowUploadRecords" />
      <el-table-column label="发货&gt;签订地址" align="center" prop="shippingAddress" />
      <el-table-column label="发货&gt;供方授权代表" align="center" prop="shippingRepresentative" />
      <el-table-column label="发货&gt;联系电话" align="center" prop="shippingContact" />
      <el-table-column label="发货&gt;公司电话" align="center" prop="shippingCompanyPhone" />
      <el-table-column label="发货&gt;单位地址" align="center" prop="shippingUnitAddress" />
      <el-table-column label="发货&gt;仓库地址" align="center" prop="shippingWarehouseAddress" />
      <el-table-column label="发货&gt;开户行&账号" align="center" prop="shippingBankAccount" />
      <el-table-column label="发货&gt;操作人员" align="center" prop="shippingOperator" />
      <el-table-column label="业务关联人" align="center" prop="businessAssociate" />
      <el-table-column label="所有人可用：所有人可用" align="center" prop="availableToAll" />
      <el-table-column label="备查状态" align="center" prop="backupStatus" />
      <el-table-column label="商业数据" align="center" prop="commercialData" />
      <el-table-column label="档案来源" align="center" prop="archiveSource" />
      <el-table-column label="创建时间" align="center" prop="createdOn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createdOn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updatedOn" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updatedOn, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hbs:bussinessArchive:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hbs:bussinessArchive:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改商业档案主档对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="客户编号" prop="customerCode">
          <el-input v-model="form.customerCode" placeholder="请输入客户编号" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="一级部门" prop="departmentLevel1">
          <el-input v-model="form.departmentLevel1" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="二级部门" prop="departmentLevel2">
          <el-input v-model="form.departmentLevel2" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="业务区域" prop="businessArea">
          <el-input v-model="form.businessArea" placeholder="请输入业务区域" />
        </el-form-item>
        <el-form-item label="负责销售(作废)" prop="salesPerson">
          <el-input v-model="form.salesPerson" placeholder="请输入负责销售(作废)" />
        </el-form-item>
        <el-form-item label="省份" prop="province">
          <el-input v-model="form.province" placeholder="请输入省份" />
        </el-form-item>
        <el-form-item label="城市" prop="city">
          <el-input v-model="form.city" placeholder="请输入城市" />
        </el-form-item>
        <el-form-item label="区县" prop="district">
          <el-input v-model="form.district" placeholder="请输入区县" />
        </el-form-item>
        <el-form-item label="单位地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入单位地址" />
        </el-form-item>
        <el-form-item label="联系人" prop="contactPerson">
          <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
        </el-form-item>
        <el-form-item label="开户行&账号" prop="bankAccount">
          <el-input v-model="form.bankAccount" placeholder="请输入开户行&账号" />
        </el-form-item>
        <el-form-item label="税号" prop="taxId">
          <el-input v-model="form.taxId" placeholder="请输入税号" />
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="传真" prop="fax">
          <el-input v-model="form.fax" placeholder="请输入传真" />
        </el-form-item>
        <el-form-item label="邮编" prop="zipcode">
          <el-input v-model="form.zipcode" placeholder="请输入邮编" />
        </el-form-item>
        <el-form-item label="网址" prop="website">
          <el-input v-model="form.website" placeholder="请输入网址" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="应收余额" prop="receivableBalance">
          <el-input v-model="form.receivableBalance" placeholder="请输入应收余额" />
        </el-form-item>
        <el-form-item label="在用品规" prop="inUseSpecs">
          <el-input v-model="form.inUseSpecs" placeholder="请输入在用品规" />
        </el-form-item>
        <el-form-item label="采购记录" prop="purchaseRecords">
          <el-input v-model="form.purchaseRecords" placeholder="请输入采购记录" />
        </el-form-item>
        <el-form-item label="首营触发" prop="firstSaleTrigger">
          <el-input v-model="form.firstSaleTrigger" placeholder="请输入首营触发" />
        </el-form-item>
        <el-form-item label="流向提交方式：手工上传、直连数据" prop="flowSubmissionMethod">
          <el-input v-model="form.flowSubmissionMethod" placeholder="请输入流向提交方式：手工上传、直连数据" />
        </el-form-item>
        <el-form-item label="流向上传记录" prop="flowUploadRecords">
          <el-input v-model="form.flowUploadRecords" placeholder="请输入流向上传记录" />
        </el-form-item>
        <el-form-item label="发货&gt;签订地址" prop="shippingAddress">
          <el-input v-model="form.shippingAddress" placeholder="请输入发货&gt;签订地址" />
        </el-form-item>
        <el-form-item label="发货&gt;供方授权代表" prop="shippingRepresentative">
          <el-input v-model="form.shippingRepresentative" placeholder="请输入发货&gt;供方授权代表" />
        </el-form-item>
        <el-form-item label="发货&gt;联系电话" prop="shippingContact">
          <el-input v-model="form.shippingContact" placeholder="请输入发货&gt;联系电话" />
        </el-form-item>
        <el-form-item label="发货&gt;公司电话" prop="shippingCompanyPhone">
          <el-input v-model="form.shippingCompanyPhone" placeholder="请输入发货&gt;公司电话" />
        </el-form-item>
        <el-form-item label="发货&gt;单位地址" prop="shippingUnitAddress">
          <el-input v-model="form.shippingUnitAddress" placeholder="请输入发货&gt;单位地址" />
        </el-form-item>
        <el-form-item label="发货&gt;仓库地址" prop="shippingWarehouseAddress">
          <el-input v-model="form.shippingWarehouseAddress" placeholder="请输入发货&gt;仓库地址" />
        </el-form-item>
        <el-form-item label="发货&gt;开户行&账号" prop="shippingBankAccount">
          <el-input v-model="form.shippingBankAccount" placeholder="请输入发货&gt;开户行&账号" />
        </el-form-item>
        <el-form-item label="发货&gt;操作人员" prop="shippingOperator">
          <el-input v-model="form.shippingOperator" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="业务关联人" prop="businessAssociate">
          <el-input v-model="form.businessAssociate" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="所有人可用：所有人可用" prop="availableToAll">
          <el-input v-model="form.availableToAll" placeholder="请输入所有人可用：所有人可用" />
        </el-form-item>
        <el-form-item label="商业数据" prop="commercialData">
          <el-input v-model="form.commercialData" placeholder="请输入商业数据" />
        </el-form-item>
        <el-form-item label="档案来源" prop="archiveSource">
          <el-input v-model="form.archiveSource" placeholder="请输入档案来源" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createdOn">
          <el-date-picker clearable
            v-model="form.createdOn"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="更新时间" prop="updatedOn">
          <el-date-picker clearable
            v-model="form.updatedOn"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择更新时间">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listBussinessArchive, getBussinessArchive, delBussinessArchive, addBussinessArchive, updateBussinessArchive } from "@/api/hbs/bussinessArchive"

export default {
  name: "BussinessArchive",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商业档案主档表格数据
      bussinessArchiveList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        archiveStatus: null,
        cooperationType: null,
        customerCode: null,
        customerName: null,
        customerType: null,
        licenseStatus: null,
        departmentLevel1: null,
        departmentLevel2: null,
        businessArea: null,
        salesPerson: null,
        province: null,
        city: null,
        district: null,
        address: null,
        contactPerson: null,
        bankAccount: null,
        taxId: null,
        phone: null,
        fax: null,
        zipcode: null,
        website: null,
        receivableBalance: null,
        inUseSpecs: null,
        purchaseRecords: null,
        firstSaleTrigger: null,
        flowSubmissionMethod: null,
        flowUploadRecords: null,
        shippingAddress: null,
        shippingRepresentative: null,
        shippingContact: null,
        shippingCompanyPhone: null,
        shippingUnitAddress: null,
        shippingWarehouseAddress: null,
        shippingBankAccount: null,
        shippingOperator: null,
        businessAssociate: null,
        availableToAll: null,
        backupStatus: null,
        commercialData: null,
        archiveSource: null,
        createdOn: null,
        updatedOn: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询商业档案主档列表 */
    getList() {
      this.loading = true
      listBussinessArchive(this.queryParams).then(response => {
        this.bussinessArchiveList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        archiveStatus: null,
        cooperationType: null,
        customerCode: null,
        customerName: null,
        customerType: null,
        licenseStatus: null,
        departmentLevel1: null,
        departmentLevel2: null,
        businessArea: null,
        salesPerson: null,
        province: null,
        city: null,
        district: null,
        address: null,
        contactPerson: null,
        bankAccount: null,
        taxId: null,
        phone: null,
        fax: null,
        zipcode: null,
        website: null,
        remark: null,
        receivableBalance: null,
        inUseSpecs: null,
        purchaseRecords: null,
        firstSaleTrigger: null,
        flowSubmissionMethod: null,
        flowUploadRecords: null,
        shippingAddress: null,
        shippingRepresentative: null,
        shippingContact: null,
        shippingCompanyPhone: null,
        shippingUnitAddress: null,
        shippingWarehouseAddress: null,
        shippingBankAccount: null,
        shippingOperator: null,
        businessAssociate: null,
        availableToAll: null,
        backupStatus: null,
        commercialData: null,
        archiveSource: null,
        createdOn: null,
        updatedOn: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = "添加商业档案主档"
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getBussinessArchive(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = "修改商业档案主档"
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateBussinessArchive(this.form).then(response => {
              this.$modal.msgSuccess("修改成功")
              this.open = false
              this.getList()
            })
          } else {
            addBussinessArchive(this.form).then(response => {
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getList()
            })
          }
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除商业档案主档编号为"' + ids + '"的数据项？').then(function() {
        return delBussinessArchive(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hbs/bussinessArchive/export', {
        ...this.queryParams
      }, `bussinessArchive_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
